<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // resolve和reject同时也是函数，因为可以调用
        
        // let time = null;
         
        // setTimeout(() =>{
        //     time = Date.now();
        //     console.log(time)
        // },1000)

        // console.log(time);

        let p = new Promise((resolve,reject) =>{
            console.log("我是promise回调函数的内部");

            setTimeout(() =>{
                time = Date.now();
                console.log('异步任务回调函数内部的结果：' + time);
                // return resolve(time);
                return reject(new Error("错误"));
            },1000)
        })
        p.then((result) =>{
            console.log("resolve传递给result的结果", result)
        },(error) =>{
            console.log("resolve传递给result的结果"+ error);
            console.log(error);
        })



        console.log('promise的外部');
    </script>
</body>
</html>